<?php
class IndexAction extends MbaseAction
{
	public $tbname = 'Set';
	public $cate = 'good_cate';
	public $obj = '';
	public $mpk = 'set_id';
    public function index()
    {
    	$newscate = $this->getCateTree('news_cate');
    	$mnews = D('News');
    	$map = array(
    		'p' => 1,
    		'ps' => 7,
    		'q' => array('cate_id' => 0)
    	);
    	$tdata = array();
    	foreach($newscate as $vo){
    		if($vo['parent_id'] == 0){
    			$map['q']['cate_id'] = $vo['cate_id'];
    			$rs = $mnews->doGet($map);
    			$tdata[$vo['cate_id']] = $rs['list'];
    		}
    	}
    	$this->assign('newslist',$tdata);
    	$this->assign('isindex',1);
    	$mbul = M('Bulletin');
    	$bmap['type'] = 1;
    	$bmap['title'] = array('neq','');
    	$gonggao = $mbul->where($bmap)->select();
    	$this->assign('gonggao',$gonggao);
    	$bmap['type'] = 0;
    	$zhuanti = $mbul->where($bmap)->select();
    	$this->assign('zhuanti',$zhuanti);
    	
    	//友情链接
    	$mflink = M('Flink');
    	$flinklist = $mflink->order('oid asc')->select();
    	$this->assign('flinklist',$flinklist);
    	
    	//热销
    	$mhotsell = M('Good');
    	$hotsells = $mhotsell->order('order_count desc')->limit(6)->select();
    	$this->assign('hotsells',$hotsells);
    	
    	//分成记录
    	$is_divide = isset($_GET['from'])? $_GET['from'] : 0;
    	if($is_divide){
    		//$old = cookie('divide_id');
    		//if(empty($old)) cookie('divide_id',$is_divide);
    		cookie('divide_id',$is_divide);
    		$mc = M('Divide_click');
			$map = array('dmember_id' => $is_divide);
			$rs = $mc->setInc('click',$map);
			if(!$rs){
				$mc->add(array('id'=>'','dmember_id'=>$is_divide,'click'=>1));
			}
			
    	}
        $this->display();
        
    }
    public function error404($info = 0){
    	if(!$info) $info = '很抱歉，您访问的页面不存在或者已被删除！';
    	$this->assign('info',$info);
    	$this->display('Public:404');
    	exit();
    }

}
?>